package com.xwltz.controller;

import com.xwltz.entity.User;
import com.xwltz.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {

    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @RequestMapping("/index")
    public ModelAndView index() {
        List<User> list = userService.findAll();
        ModelAndView modelAndView = new ModelAndView("index", "list", list);
        return modelAndView;
    }
}
